package Interface.lianxi06;
interface  Light{
void shine();
}
class RedLight implements  Light{

    @Override
    public void shine() {
        System.out.println("Red Light shine in Red");
    }
}
class  YellowLight implements  Light{

    @Override
    public void shine() {
        System.out.println("Yellow Light shine in Yellow");
    }
}
class GreenLight implements  Light{

    @Override
    public void shine() {
        System.out.println("Green Light shine on Green");
    }
}
class Lamp{
    private Light light;
    public void setLight(Light light){
        this.light=light;
    }
     void on(){
    light.shine();
    }
}
public class TestInterface {
    public static void main(String[] args) {
        Light[] lights = new Light[3];
        lights[0] = new RedLight();
        lights[1] = new YellowLight();
        lights[2] = new GreenLight();
        Lamp lamp = new Lamp();
        for (int i = 0; i < lights.length; i++) {
            lamp.setLight(lights[1]);
            lamp.on();
        }
    }


}
